#include "head.h"
void f_test()
{
    int fd  = open("1.txt",O_RDONLY|O_CREAT|O_TRUNC,0666);
    if(fd<0){
        perror("open file");
        exit(1);
    }

    u_int32_t r= fcntl(fd,F_GETFL);
    if( (r&O_ACCMODE) ==  O_RDWR){
        printf("O_RDWR\n");
    }
    if( (r&O_ACCMODE) == O_WRONLY){
        printf("O_WRONLY\n");
    }
    if((r&O_ACCMODE) ==  O_RDONLY ){
        printf("O_RDONLY\n");
    }

    close(fd);
}